Skip to content

Small improvements and fix#114

Merged
panicking merged 3 commits intojenkinsci:masterfrom
panicking:small-improvements-and-fix
Apr 28, 2025
Merged

Small improvements and fix#114
panicking merged 3 commits intojenkinsci:masterfrom
panicking:small-improvements-and-fix

Conversation

@panicking
Copy link
Contributor

@panicking panicking commented Apr 1, 2025

We established a Jenkins multibranch pipeline project to monitor multiple Bitbucket repositories, specifically designed for building complex operating systems like Yocto. This setup leverages the Jenkins Remote File Provider plugin (https://plugins.jenkins.io/remote-file/) to enable the use of a single Jenkinsfile across all monitored repositories (e.g., meta-company, meta-extra-company).

Our infrastructure includes Jenkins behind a firewall, which initially caused webhook crumb issues. To resolve this, we employed smee.io to bypass the firewall and facilitate reliable webhook delivery from Bitbucket Cloud to Jenkins.

The Jenkins instance utilizes the Bitbucket Branch Source plugin, resulting in requests being processed as BitbucketSCMSource. This source, however, lacked the getRemote method, requiring specific patches for proper functionality.

Testing done

Testing was conducted within our infrastructure, confirming successful build triggering upon both push and pull request events from Bitbucket Cloud to our firewall-protected Jenkins instance

@panicking panicking force-pushed the small-improvements-and-fix branch from 6863a06 to 210fea0 Compare April 1, 2025 17:42
@panicking panicking requested a review from a team as a code owner April 1, 2025 17:42
@panicking panicking force-pushed the small-improvements-and-fix branch 2 times, most recently from 1422b8b to b0f3b85 Compare April 6, 2025 08:26
Copy link

@KalleOlaviNiemitalo KalleOlaviNiemitalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually using this plugin, so the changes won't affect me either way, but I wanted to share my observations.

Comment on lines +102 to +106
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-bitbucket-branch-source</artifactId>
</dependency>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could perhaps be an optional dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KalleOlaviNiemitalo what will be the case in an official delivery where this then is not included? I think that in this area I'm newbie.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, you can make the Bitbucket plugin check at run time whether the Bitbucket Branch Source plugin has been installed; if it has not been installed, then skip the scm instanceof BitbucketSCMSource checks so that class BitbucketSCMSource need not exist. There are instructions in https://www.jenkins.io/doc/developer/plugin-development/optional-dependencies/. But this is only a suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, make sense. I will give a try on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +227 to +238
gitRemote = ((BitbucketSCMSource) scm).getServerUrl() + "/" +
((BitbucketSCMSource) scm).getRepoOwner() + "/" +
((BitbucketSCMSource) scm).getRepository();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL structure looks specific to Bitbucket Cloud, incompatible with Server and Data Center.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KalleOlaviNiemitalo this define a generic match. Why should be incompatible? The code just decouple a different type coming.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. In Bitbucket Server, the web UI uses URLs like https://bitbucket.example:8443/projects/DEMOPROJ/repos/demorepo/browse, which includes the "projects" and "repos" keywords. I worried that this pull request does not add those keywords and might then be incompatible. However, in Bitbucket Server, git clone uses URLs like ssh://git@bitbucket.example:7999/DEMOPROJ/demorepo.git or https://bitbucket.example:8443/scm/demoproj/demorepo.git; these do not include the "projects" and "repos" keywords. So this pull request seems compatible after all.

@panicking panicking force-pushed the small-improvements-and-fix branch from b0f3b85 to 3dbaa03 Compare April 6, 2025 14:21
@KalleOlaviNiemitalo
Copy link

Because I'm not using this plugin and am not a real Java programmer, I don't feel I can review this properly.

But, please give the pull request a more descriptive title so that users who read the release notes will understand what changed.

@panicking
Copy link
Contributor Author

@jenkinsci/bitbucket-plugin-developers Hi there, any time to review this patch?

…/bitbucket-hook

Allow to run webhook behind a firewall (example smee.io)

Before:
sirio smee[2620767]: POST http://127.0.0.1:8080/bitbucket-hook/ - 403

After:
sirio smee[2620767]: POST http://127.0.0.1:8080/bitbucket-hook/ - 200

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Extend the plugin to support the BitbucketSCMSource. This allow
to trigger build coming from this source

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
if( to if ( and ){ to ) {

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
@panicking panicking force-pushed the small-improvements-and-fix branch from 3dbaa03 to 4763f88 Compare April 28, 2025 18:15
@panicking panicking merged commit dbc342a into jenkinsci:master Apr 28, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants